package com.example.wechattakeaway.controller;

import com.example.wechattakeaway.form.orderform.InsertOrderDetailForm;
import com.example.wechattakeaway.service.OrderDetailService;
import com.example.wechattakeaway.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Api(value = "订单详情管理",tags = {"订单详情操作接口"})
@RestController
@RequestMapping("/OrderDetailController")
public class OrderDetailController {

    @Autowired
    OrderDetailService orderDetailService;

    @ApiOperation("新增一条订单详情")
    @PostMapping("/InsertOrderDetail")
    public ResultVO InsertOrderDetail(InsertOrderDetailForm insertOrderDetailForm){
        return orderDetailService.InsertOrderDetail(insertOrderDetailForm);
    }

    @ApiOperation("根据id查询一个订单详情")
    @PostMapping("/SelectOrderDetailById")
    public ResultVO SelectOrderDetailById(Integer orderDetailId){
        return orderDetailService.SelectOrderDetailById(orderDetailId);
    }

    @ApiOperation("根据一个订单id查询该订单所有详情")
    @PostMapping("/SelectOrderDetailByOrder")
    public ResultVO SelectOrderDetailByOrder(Integer pageNum,Integer orderId){
        return orderDetailService.SelectOrderDetailByOrder(pageNum,orderId);
    }

}
